﻿/*================================================================================
	TASK 4:                                                               {Arrays}
	Write a program that finds the maximal sequence of equal elements in an array.
	Example: {2, 1, 1, 2, 3, 3, 2, 2, 2, 1} => {2, 2, 2}. 
================================================================================*/

using System;
using System.Collections.Generic;

class FindTheMaximalSequence
{
    static void Main()
    {
        //Console.Write("Enter size of array:");
        //int size = int.Parse(Console.ReadLine());

        //int[] array = new int[size];
        //for (int index = 0; index < array.Length; index++)
        //{
        //    array[index] = int.Parse(Console.ReadLine());
        //}
        int[] array = {5,5,5,5,5,3,1,1,2,2,2,2,1,1};

        List<int> maximumSeqArray = new List<int>();

        int lenght = 1;
        int maxLenght = 1;
        int start = 0;
        int maxStart = 0;

        for (int index = 0; index < array.Length - 1; index++)
        {
            if (array[index] == array[index + 1])
            {
                lenght++;

                if (lenght > maxLenght)
                {
                    maxLenght = lenght;
                    maxStart = start;
                }
            }
            else
            {
                lenght = 1;
                start = index + 1;
            }
        }
        
        Console.WriteLine(maxStart);
        Console.WriteLine(maxLenght);

        for (int i = maxStart; i <= maxStart + maxLenght-1; i++)
        {
            Console.Write(array[i] +"");
        }

        //Console.WriteLine(lenght);
        //Console.WriteLine(maxLenght);

        //for (int index = 0; index < array.Length - 1; index++)
        //{


        //    if (array[index] == array[index + 1])
        //    {
        //        newFirstElement = array[index];

        //        if (oldFirstElement != newFirstElement)
        //        {
        //            newSequence.Clear();
        //        }

        //        newSequence.Add(array[index]);

        //        if (oldSequence.Count > newSequence.Count)
        //        {
        //            newSequence = oldSequence;
        //            newFirstElement = oldFirstElement;
        //        }

        //    }
           
        //        oldSequence = newSequence;
        //        oldFirstElement = newFirstElement;
        //}

        //newSequence.Add(newFirstElement);

        //for (int i = 0; i < newSequence.Count; i++)
        //{
        //    Console.Write(newSequence[i] + "");
        //}
    }
}

